<template>
    <div>
        <el-table border :data="list" style="width: 100%">
            <el-table-column prop="name" label="课程" />
            <el-table-column prop="studentName" label="学生姓名" />
            <el-table-column prop="text" label="原因" />
            <el-table-column prop="laoshi" label="老师" />
            <el-table-column label="操作" >
                <template #default="scope">
                    <!-- {{scope.row}} -->
                    <el-button type="primary" @click="faqi(scope.row)">评分</el-button>
                </template>
</el-table-column>
</el-table>
</div>
</template>
<script setup>
    import {
        onMounted,
        ref
    } from 'vue'
    import {
        pigaiList,
        pingfen
    } from "~/api/xm.js"
    import {
        useStore
    } from 'vuex'
    import {
        ElMessage,
        ElMessageBox
    } from 'element-plus'
    const store = useStore()
    const list = ref([])

    function faqi(row) {
        console.log(row);
        ElMessageBox.prompt('请输入分数', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
            })
            .then(({
                value
            }) => {
                pingfen({
                    id: row.id,
                    scope: value
                }).then(res => {
                    if (res.code == 200) {
                        ElMessage({
                            type: 'success',
                            message: `审批成功`,
                        })
                        getList()
                    }
                })
                console.log(value);

            })
    }
    onMounted(() => {
        getList()
    })

    function getList() {
        pigaiList({
            laoshiId: store.state.studentId
        }).then(res => {
            list.value = res.data
            console.log(res);
        })
    }
</script>